Definitions
Greedy algorithms make the locally optimal choice at each stage with the hope of finding a global optimum. Here's how they work:
Principles
- Local Optimality: At each step, choose the option that seems best at the moment.
- Feasibility: Ensure the choice is still feasible and does not violate any constraints.
Common Problems
- Activity Selection: Choose the maximum number of compatible activities.
- Huffman Coding: Build a binary tree to optimize data encoding.
Greedy algorithms are efficient and can be applied to a variety of problems, but they don't always guarantee the best solution.